import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { Student } from '../../student/entities/student.entity';
import { ClassInfo } from '../../class-info/entities/class-info.entity';
import { Major } from '../../major/entities/major.entity';

/**
 * 学院名称
 */
@Entity()
export class Department {
  @PrimaryGeneratedColumn({ type: 'int', comment: '学院编号' })
  id: number;

  @Column({ comment: '学院名称', unique: true })
  name: string;

  @Column({ comment: '描述', nullable: true })
  desc: string;

  @OneToMany(() => Student, (student) => student.department, {
    onDelete: 'SET NULL',
  })
  student: Student[];

  @OneToMany(() => Major, (major) => major.department, {
    onDelete: 'SET NULL',
  })
  major: Major[];
}
